<?php
namespace Common;

use Common\BaseController;

class LoginBaseController extends BaseController{
	protected $_defaultAuthList=array();
	/**
	 * 初始化操作
	 */
	protected function _initialize(){
		// 加载消息提示插件
		B( 'Common\Behavior\Notice' );
	}
	
	/**
	 * 获取用户权限
	 * m:moudle,c:controller,a:action
	 * @param array $userInfo
	 */
	protected function getUserAuth($userInfo){
		$auth = array();
        $ename=M("Admin")->where("id='%d'",$userInfo['id'])->find();
        if($ename['eName']=="super_admin"){
            $auth['org']="super";
        }
       //获取用户角色
        $auth_id=array();
        $role=$this->getUserRole($userInfo);
        foreach($role as $k=>$v){
            if($v['eName']=="super_admin"){
                $auth['org']="super";
            }
            $node_id=M("role_node")->where("role_id='%d'",$v['id'])->select();
            foreach($node_id as $key=>$val){
                $auth_id[]=$val['node_id'];
            }
        }
        $res=array_unique($auth_id);
        $authData=M("Node")->where("id in (".implode(',',$res).")")->select();
        $auth['m'][]="Admin";
        foreach($authData as $k=>$v){
            $c[]=$v['controller'];
            $auth['a'][$v['controller']][]=$v['action'];
        }
        $auth['c']=array_unique($c);
		return $auth;
	}
}

?>